Differentiates documentation and compilation in user output
authorEdward Yang <edward.yang6771@gmail.com>
Sun, 11 Oct 2015 18:33:55 +0000 (13:33 -0500)
committerEdward Yang <edward.yang6771@gmail.com>
Fri, 16 Oct 2015 03:17:56 +0000 (22:17 -0500)
Fix tests to work with new jobqueue

src/cargo/ops/cargo_rustc/job_queue.rs
tests/support/mod.rs
tests/test_cargo_compile_custom_build.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_doc.rs

index 554889649ce79c1096b892e0629be9750f72127d..5966ca3edbf126d029cccfddc6ec9e0fd33e7773 100644 (file)
@@ -25,7 +25,8 @@ pub struct JobQueue<'a> {
     rx: Receiver<Message<'a>>,
     active: usize,
     pending: HashMap<Key<'a>, PendingBuild>,
-    printed: HashSet<&'a PackageId>,
+    compiled: HashSet<&'a PackageId>,
+    documented: HashSet<&'a PackageId>,
     counts: HashMap<&'a PackageId, usize>,
 }
 
@@ -61,7 +62,8 @@ impl<'a> JobQueue<'a> {
             rx: rx,
             active: 0,
             pending: HashMap::new(),
-            printed: HashSet::new(),
+            compiled: HashSet::new(),
+            documented: HashSet::new(),
             counts: HashMap::new(),
         }
     }
@@ -181,7 +183,7 @@ impl<'a> JobQueue<'a> {
         });
 
         // Print out some nice progress information
-        try!(self.note_working_on(config, key.pkg, fresh));
+        try!(self.note_working_on(config, &key, fresh));
 
         // only the first message of each job is processed
         if let Ok(msg) = desc_rx.recv() {
@@ -199,9 +201,10 @@ impl<'a> JobQueue<'a> {
     // In general, we try to print "Compiling" for the first nontrivial task
     // run for a package, regardless of when that is. We then don't print
     // out any more information for a package after we've printed it once.
-    fn note_working_on(&mut self, config: &Config, pkg: &'a PackageId,
+    fn note_working_on(&mut self, config: &Config, key: &Key<'a>,
                        fresh: Freshness) -> CargoResult<()> {
-        if self.printed.contains(&pkg) {
+        if (self.compiled.contains(key.pkg) && !key.profile.doc) || 
+            (self.documented.contains(key.pkg) && key.profile.doc) {
             return Ok(())
         }
 
@@ -209,12 +212,17 @@ impl<'a> JobQueue<'a> {
             // Any dirty stage which runs at least one command gets printed as
             // being a compiled package
             Dirty => {
-                self.printed.insert(pkg);
-                try!(config.shell().status("Compiling", pkg));
+                if key.profile.doc {
+                    self.documented.insert(key.pkg);
+                    try!(config.shell().status("Documenting", key.pkg));
+                } else {
+                    self.compiled.insert(key.pkg);
+                    try!(config.shell().status("Compiling", key.pkg));
+                }
             }
-            Fresh if self.counts[pkg] == 0 => {
-                self.printed.insert(pkg);
-                try!(config.shell().verbose(|c| c.status("Fresh", pkg)));
+            Fresh if self.counts[key.pkg] == 0 => {
+                self.compiled.insert(key.pkg);
+                try!(config.shell().verbose(|c| c.status("Fresh", key.pkg)));
             }
             Fresh => {}
         }
index 55589f35054b5ed5a284c18c75a80ff9fb92d812..38e4348705d23fb958f213456d5ce411f7f01e82 100644 (file)
@@ -552,6 +552,7 @@ pub fn path2url(p: PathBuf) -> Url {
 
 pub static RUNNING:     &'static str = "     Running";
 pub static COMPILING:   &'static str = "   Compiling";
+pub static DOCUMENTING: &'static str = " Documenting";
 pub static FRESH:       &'static str = "       Fresh";
 pub static UPDATING:    &'static str = "    Updating";
 pub static ADDING:      &'static str = "      Adding";
index a28bd463301b4952d42808178b70d7cf4ecaf2a1..e21718a22a3a6c62365cbb87bc690953a86384bd 100644 (file)
@@ -2,7 +2,7 @@ use std::fs::File;
 use std::io::prelude::*;
 
 use support::{project, execs};
-use support::{COMPILING, RUNNING, DOCTEST, FRESH};
+use support::{COMPILING, RUNNING, DOCTEST, FRESH, DOCUMENTING};
 use support::paths::CargoPathExt;
 use hamcrest::{assert_that};
 
@@ -506,9 +506,9 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
     assert_that(p.cargo("doc").arg("-v"),
                 execs().with_status(0)
                        .with_stdout(&format!("\
-{compiling} foo v0.5.0 (file://[..])
+{documenting} foo v0.5.0 (file://[..])
 {running} `rustdoc [..]`
-", compiling = COMPILING, running = RUNNING)));
+", documenting = DOCUMENTING, running = RUNNING)));
 
     File::create(&p.root().join("src/main.rs")).unwrap()
          .write_all(b"fn main() {}").unwrap();
index cb9725763d70375dcbb93d5cc921851a719119c4..ca75fac3548f82c5ae4243a3fee373eb78877694 100644 (file)
@@ -565,25 +565,29 @@ test!(build_script_needed_for_host_and_target {
 
     assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
                 execs().with_status(0)
-                       .with_stdout(&format!("\
-{compiling} d1 v0.0.0 ({url})
-{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`
-{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`
-{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`
-{running} `rustc d1[..]src[..]lib.rs [..]`
-{running} `rustc d1[..]src[..]lib.rs [..]`
-{compiling} d2 v0.0.0 ({url})
+                       .with_stdout_contains(&format!("\
+{compiling} d1 v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
+                       .with_stdout_contains(&format!("\
+{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", 
+    running = RUNNING, dir = p.root().display()))
+                       .with_stdout_contains(&format!("\
+{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`", running = RUNNING, 
+    dir = p.root().display()))
+                       .with_stdout_contains(&format!("\
+{running} `rustc d1[..]src[..]lib.rs [..]`", running = RUNNING))
+                       .with_stdout_contains(&format!("\
+{compiling} d2 v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
+                       .with_stdout_contains(&format!("\
 {running} `rustc d2[..]src[..]lib.rs [..] \
-           -L /path/to/{host}`
-{compiling} foo v0.0.0 ({url})
+           -L /path/to/{host}`", running = RUNNING, host = host))
+                       .with_stdout_contains(&format!("\
+{compiling} foo v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
+                       .with_stdout_contains(&format!("\
 {running} `rustc build.rs [..] --out-dir {dir}[..]target[..]build[..]foo-[..] \
-           -L /path/to/{host}`
-{running} `{dir}[..]target[..]build[..]foo-[..]build-script-build`
+           -L /path/to/{host}`", running = RUNNING, dir = p.root().display(), host = host))
+                       .with_stdout_contains(&format!("\
 {running} `rustc src[..]main.rs [..] --target {target} [..] \
-           -L /path/to/{target}`
-", compiling = COMPILING, running = RUNNING, target = target, host = host,
-   url = p.url(),
-   dir = p.root().display())));
+           -L /path/to/{target}`", running = RUNNING, target = target)));
 });
 
 test!(build_deps_for_the_right_arch {
index 935178379785dca91d563d7fa4bfccb6afe5f129..24628d28af9aaf66f41bf125db208044c7546ad9 100644 (file)
@@ -1,7 +1,7 @@
 use std::str;
 
 use support::{project, execs, path2url};
-use support::{COMPILING, RUNNING};
+use support::{COMPILING, DOCUMENTING, RUNNING};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 
 fn setup() {
@@ -23,9 +23,9 @@ test!(simple {
 
     assert_that(p.cargo_process("doc"),
                 execs().with_status(0).with_stdout(&format!("\
-{compiling} foo v0.0.1 ({dir})
+[..] foo v0.0.1 ({dir})
+[..] foo v0.0.1 ({dir})
 ",
-        compiling = COMPILING,
         dir = path2url(p.root()))));
     assert_that(&p.root().join("target/doc"), existing_dir());
     assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
@@ -65,9 +65,9 @@ test!(doc_twice {
 
     assert_that(p.cargo_process("doc"),
                 execs().with_status(0).with_stdout(&format!("\
-{compiling} foo v0.0.1 ({dir})
+{documenting} foo v0.0.1 ({dir})
 ",
-        compiling = COMPILING,
+        documenting = DOCUMENTING,
         dir = path2url(p.root()))));
 
     assert_that(p.cargo("doc"),
@@ -101,10 +101,11 @@ test!(doc_deps {
 
     assert_that(p.cargo_process("doc"),
                 execs().with_status(0).with_stdout(&format!("\
-{compiling} bar v0.0.1 ({dir})
-{compiling} foo v0.0.1 ({dir})
+[..] bar v0.0.1 ({dir})
+[..] bar v0.0.1 ({dir})
+{documenting} foo v0.0.1 ({dir})
 ",
-        compiling = COMPILING,
+        documenting = DOCUMENTING,
         dir = path2url(p.root()))));
 
     assert_that(&p.root().join("target/doc"), existing_dir());
@@ -148,9 +149,9 @@ test!(doc_no_deps {
     assert_that(p.cargo_process("doc").arg("--no-deps"),
                 execs().with_status(0).with_stdout(&format!("\
 {compiling} bar v0.0.1 ({dir})
-{compiling} foo v0.0.1 ({dir})
+{documenting} foo v0.0.1 ({dir})
 ",
-        compiling = COMPILING,
+        documenting = DOCUMENTING, compiling = COMPILING,
         dir = path2url(p.root()))));
 
     assert_that(&p.root().join("target/doc"), existing_dir());
@@ -243,9 +244,10 @@ test!(doc_dash_p {
     assert_that(p.cargo_process("doc").arg("-p").arg("a"),
                 execs().with_status(0)
                        .with_stdout(&format!("\
-{compiling} b v0.0.1 (file://[..])
-{compiling} a v0.0.1 (file://[..])
-", compiling = COMPILING)));
+[..] b v0.0.1 (file://[..])
+[..] b v0.0.1 (file://[..])
+{documenting} a v0.0.1 (file://[..])
+", documenting = DOCUMENTING)));
 });
 
 test!(doc_same_name {
@@ -428,9 +430,9 @@ test!(doc_release {
     assert_that(p.cargo("doc").arg("--release").arg("-v"),
                 execs().with_status(0)
                        .with_stdout(&format!("\
-{compiling} foo v0.0.1 ([..])
+{documenting} foo v0.0.1 ([..])
 {running} `rustdoc src[..]lib.rs [..]`
-", compiling = COMPILING, running = RUNNING)));
+", documenting = DOCUMENTING, running = RUNNING)));
 });
 
 test!(doc_multiple_deps {